import { observable, action } from "mobx"
import { Item } from "antd-mobile/lib/tab-bar";
class Video {
    constructor(rootStore) {
        this.rootStore = rootStore
        console.log( this.rootStore)
    }
    @observable list=[]
    //说明 : 调用此接口 , 可获取视频排行榜 
    
    @action.bound getViolist(value) {
        fetch(`http://106.12.79.128:666/top/mv?limit=10&area${value}`)
        .then(body => body.json())
        .then(result => {
            this.setViolist(result.data)
        })
    }
    @action.bound setViolist(list){
        try{
            this.list = [...list]
        }catch{
            console.log('error')
        }
       
    }




    @observable Play_address={}
    
    //说明 : 调用此接口 , 可根据id获取MV播放地址 
    
    @action.bound getSrc(value) {
        fetch(`http://106.12.79.128:666/mv/detail?mvid=${value}`)
        .then(body => body.json())
        .then(result => {
            this.setSrc(result.data.brs[240])
        })
    }
    @action.bound setSrc(list){
        this.Play_address = list
    }
    //获取MV的详细信息
    @observable Play_data={}
    @action.bound get_data(value) {
        fetch(`http://106.12.79.128:666/mv/detail?mvid=${value}`)
        .then(body => body.json())
        .then(result => {
            this.set_data(result.data)
        })
    }
    @action.bound set_data(list){
        this.Play_data = list
    }
    //获取相关推荐
    //传入ID
    @observable lol_ost=[]
    @action.bound get_lol_ost(value) {
        fetch(`http://106.12.79.128:666/related/allvideo?id=${value}`)
        .then(body => body.json())
        .then(result => {
            this.set_lol_ost(result.data)
            console.log( result.data[0].title )
        })
    }
    @action.bound set_lol_ost(list){
        
        this.lol_ost = list
        
  
    }
   
   
}
export default Video